<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('网店商品信息')"/>
    <th:block th:include="include :: list-css"/>
    <style type="text/css">
        label.layui-form-label {
            width: 95px;
            padding-right: 0px;
        }

        .layui-form-radio {
            margin-top: 0
        }

        .importTable {
            empty-cells: show;
            border-collapse: collapse;
            border-spacing: 0;
        }

        .listext th {
            background: #eee;
            color: #3366cc;
        }

        .listext th, .listext td {
            border: solid 1px #ddd;
            text-align: left;
            padding: 10px;
            font-size: 14px;
        }

        #importProgress {
            z-index: 20200202;
            background-color: #000;
            opacity: 0.3;
            display: none;
        }

        .importProgress {
            width: 300px;
            z-index: 20202222;
            position: fixed;
            top: 34%;
            left: 40%;
            display: none;
        }

        /* .layui-table-box{overflow-x: auto !important;}
        .layui-table-header{display: inline-block !important;} */
    </style>
</head>
<body>
<div class="main-content">
    <div class="content-right">
        <div class="search-top">
            <span>查询条件</span>
            <a href="javascript:;" layadmin-event="flexible" class="menuBtn">
                <i class="layui-icon layui-icon-spread-left" id="LAY_app_flexible" style="color: #fff;"></i>
            </a>
        </div>
        <div class="panel layout-expand layui-expand-east">
            <div class="panel-header">
                <div class="panel-tool" style="text-align: center; width: 26px;height: 30px;line-height: 30px;">
                    <a href="javascript:;" layadmin-event="flexible" class="menuBtn">
                        <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible" style="color: #fff;"></i>
                    </a>
                </div>
            </div>
            <div class="panel-body panel-title" style="text-align: center; width: 26px;">查<br>询<br>条<br>件</div>
        </div>
        <form class="layui-form">
            <th:block th:include="listinclude :: searchRight('page')"/>
        </form>
    </div>
    <div class="mid-content">
        <table class="layui-hide" id="dhtable" lay-filter="ftable1"></table>
    </div>
</div>
<!-- 表格头部工作栏-->
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <div class="layui-btn layui-table-tools sdbtn" lay-event="sdbtn" th:if="${extraButton.sdbtn}">
            <i class="dhicon dh-random"></i> 手动刷新
        </div>

        <div class="layui-btn layui-table-tools importbtn-bg" lay-event="exportbtn"
             shiro:hasPermission="hr:amazonshoporder:export">
            <i class="dhicon dh-download"></i> 导出
        </div>
    </div>
</script>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: businessJS"/>
<th:block th:include="include :: searchJS"/>
<th:block th:include="include :: listJS" />
<th:block th:include="listinclude :: list-templeat"/>
<script th:inline="javascript">
    /*<![CDATA[*/
    var prefix = ctx + "hr/amazonshoporder";
    var gridColumns = [[${gridColumns}]],
        ali1688EcpApiUrl = [[${ali1688EcpApiUrl}]],
        session = [[${session}]],
        extraButton = [[${extraButton}]],
        moduleTable = [[${moduleTable}]];
    tableUrl = prefix+"/list";
    /*]]>*/
</script>
<script type="text/javascript">
    var element, thStr;
    var fieldWidth = {},		//导入列表字段宽度
        filedRequired = {},		//导入列表必填字段
        dateFiled = [],			//导入列表日期字段
        hasNull = false;		//导入数据必填字段有空值
    $.each(gridColumns.dictionaryForPageFieldList, function (i, v) {
        fieldWidth[v.fields] = v.fieldFrontWidth
        if (v.fieldFrontRequired) filedRequired[v.fields] = v.fieldName;
        if (v.fieldFrontType == 't_date') dateFiled.push(v.fields);
    })
    var $, layer, laydate, form, table, wherestr = {};
    layui.use(['table', 'laydate', 'form', 'layer', 'jquery', 'element'], function () {
        $ = layui.$, layer = layui.layer, laydate = layui.laydate , form = layui.form, table = layui.table, element = layui.element;

        //监听排序事件
        table.on('sort(ftable1)', function (obj) {
            $.tablelist.sort('dhtable', obj);
        });


        //头工具栏事件
        table.on('toolbar(ftable1)', function (obj) {
            switch (obj.event) {
                case 'exportbtn':
                    $.ajax({
                        url: '/hr/amazonshoporder/export',
                        type: 'GET',
                        data: getWherestr(),
                        dataType: 'json',
                        beforeSend: function () {
                            showloadings(true);
                        },
                        success: function (result) {
                            if (result.code == 0) {
                                window.location.href = ctx + "common/download?fileName=" + encodeURIComponent(result.msg) + "&delete=" + true;
                                parent.$('.page-loading').hide();//页面进行了跳转刷新，需要手动关闭页面的加载动画
                            } else if (result.code == web_status.WARNING) {
                                $.modal.alertWarning(result.msg)
                            } else {
                                $.modal.alertError(result.msg);
                            }
                            showloadings(false);
                        }
                    });
                    break;
                case 'sdbtn'://店铺订单 手动刷新
                    // getMore("refresh",null,"网店","tp_amazonshop",false,false,true);
                    var w=($(window).width()*0.8);
                    var h=($(window).height() - 100);
                    var index = layer.open({
                        type: 2,
                        area: [w+'px', h +'px'],
                        fix: true,
                        maxmin: false,
                        shadeClose: true,
                        shade:0.4,
                        title: "手动刷新",
                        content: '/common/dataExecution/list'
                    });
                    break;
                case 'tableFull'://表格展开
                    $('.north .layui-form').hide();
                    table.reload('dhtable',{
                        defaultToolbar: [{title:'收缩',layEvent:'tableShrink',icon:'layui-icon-screen-restore'}],
                        height: $(window).height()-$('.north').height()-60<300?'300':$(window).height()-( $('.north').height()+$('.south').height()+12)
                    });
                    break;
                case 'tableShrink'://表格收缩
                    $('.north .layui-form').show();
                    table.reload('dhtable',{
                        defaultToolbar: [{title:'展开',layEvent:'tableFull',icon:'layui-icon-screen-full'}],
                        height: $(window).height()-$('.north').height()-60<300?'300':$(window).height()-( $('.north').height()+$('.south').height()+12)
                    });
                    break;
                case 'fieldSet':
                    filedSet(moduleTable);
                    break;
            }
        });

        window.getMoreAfter=function(fieldsList, fields, tindex, fieldName, fieldSearchType, isSearch, isLayer, res){
            if(fields=='refresh'){
                    var index = layer.load();
                    $.post(ali1688EcpApiUrl + '/api/amazon/getAmazonOrderInfo', {
                        'userId': session.userId,
                        'shopGuids':res.guid
                    }, function (result) {
                        if (result.success == true) {
                            setTimeout(function () {
                                table.reload('dhtable', {page: {curr: 1}, where: getWherestr()});
                            }, 1000);
                            layer.closeAll();
                        } else {
                            layer.alert(result.message, {icon: 2});
                        }
                        layer.close(index);//取消等待
                    });
            }
        }
    });


</script>
</body>
</html>